package test;

import java.io.IOException;
import java.lang.reflect.Method;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.junit.Test;

public class Demo1 {
	@Test
	public void test1(HttpServletRequest req, HttpServletResponse resp) {
		String name = "add";
		System.out.println(Demo1.class);
		System.out.println();
		System.out.println("反射");
		try {
			Class clazz = this.getClass();
			System.out.println(clazz);
			Method method = clazz.getMethod(name,null);
			System.out.println(method);
			Object invoke = method.invoke(this, null);
			System.out.println(invoke);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
	public void add(HttpServletRequest req, HttpServletResponse resp) {
		System.out.println("add");
		try {
			resp.sendRedirect("sssss");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
